package com.xb.cloud.front.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.xb.cloud.common.JsonUtils;
import com.xb.cloud.front.common.FrontCategoryService;
import com.xb.cloud.gateway.client.RtnCodes;
import com.xb.cloud.gateway.client.RtnInfo;
import com.xb.cloud.product.category.service.client.CategoryTreeService;
import com.xb.cloud.service.client.ServiceReturnCodes;
import com.xb.cloud.service.client.ServiceReturnInfo;

/**
 * 
 * @ClassName: FrontCategoryServiceImpl
 * @Description:TODO
 * @author: 鲜备科技
 * @date: 2018年1月8日 上午11:19:14
 * 
 * @Copyright: 2018 www.xianbeitech.com Inc. All rights reserved.
 *
 */
@Service
public class FrontCategoryServiceImpl implements FrontCategoryService {
	@Autowired
	private CategoryTreeService categoryTreeService;

	@Override
	public RtnInfo getFrontCategory(long companyId) {
		RtnInfo rtnInfo = null;

		ServiceReturnInfo serviceReturnInfo = categoryTreeService.getFrontCategory(companyId);
		if (ServiceReturnCodes.SUCCESS.getCode().equals(serviceReturnInfo.getCode())) {
			rtnInfo = new RtnInfo();
			rtnInfo.setRtnCode(RtnCodes.SUCCESS);
			rtnInfo.setData(JsonUtils.beanToStringWithLong(serviceReturnInfo.getData()));
		} else {
			// TODO:异常结果处理
		}
		return rtnInfo;
	}
	/**
	 * 获取导航类目树
	 * <p>Title: getNavCategory</p>   
	 * <p>Description: </p>   
	 * @param companyId
	 * @return   
	 * @see com.xb.cloud.front.common.FrontCategoryService#getNavCategory(long)
	 */
	@Override
	public RtnInfo getNavCategory(long companyId) {
		RtnInfo rtnInfo = null;

		ServiceReturnInfo serviceReturnInfo = categoryTreeService.getNavCategory(companyId);
		if (ServiceReturnCodes.SUCCESS.getCode().equals(serviceReturnInfo.getCode())) {
			rtnInfo = new RtnInfo();
			rtnInfo.setRtnCode(RtnCodes.SUCCESS);
			rtnInfo.setData(serviceReturnInfo.getData());
		} else {
			// TODO:异常结果处理
		}
		return rtnInfo;
	}

}
